import React, { useState, useEffect } from 'react'
import { useSelector } from 'react-redux'
import { Button } from 'antd'

export default function AuthButton(props) {
    const [showBtn, setShowBtn] = useState(false)
    const btnAuth = useSelector(state => state.user.permission)
    console.log('按钮权限：', btnAuth);

    useEffect(() => {
        const isB = btnAuth.some(item => item.menuName === props.type)
        console.log('是否有权限：', isB);
        setShowBtn(isB)
    }, isB)

    return (
        showBtn ? <Button>{props.type}</Button> : null
    )
}
